package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Menu;
import com.itheima.service.MenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Reference
    private MenusService menusService;


    @RequestMapping("/findMenuByName")
    public Result findMenusByUsername (String name){
        try {
            List<Menu> menusByUsername = menusService.findMenusByUsername(name);
            return new Result(true,"success",menusByUsername);
        } catch (Exception e) {
            String message = e.getMessage();
            e.printStackTrace();
            return new Result(false,message);
        }


    }
}
